package Jun13.index;

import Jun13.utils.ESUtils;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.CreateIndexResponse;

import java.io.IOException;

public class CreateIndex {

    public static void main(String[] args) throws IOException {
        RestHighLevelClient rest = ESUtils.getRest();//获取操作es的对象
        CreateIndexRequest index = new CreateIndexRequest("user");//创建一个索引
        CreateIndexResponse create = rest.indices().create(index, RequestOptions.DEFAULT);//通过操作es对象发送创建索引的请求
        System.out.println(create.isAcknowledged());//打印创建索引成功信息
        rest.close();//关闭操作es的对象
    }
}
